<?php
/**
 * Created by PhpStorm.
 * User: zhoujinda
 * Date: 2015/12/10
 * Time: 16:24
 */

namespace Test\Controller;


use Common\Api\BoyeServiceApi;

class TestCodeController extends TestController{

    public function index(){
        $this->display();
    }

    public function sendSms(){
        if(IS_POST){
            $mobile = I('post.mobile','');
            $code_type = I('post.code_type','');

            $data = array(
                'mobile'=>$mobile,
                'code_type'=>$code_type,
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Message_send_sms',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result= $service->callRemote("",$data,true);

            $this->parseResult($result);
        }
        $this->display();
    }

    public function checkCode(){
        if(IS_POST){
            $mobile = I('post.mobile','');
            $code = I('post.code','');
            $code_type = I('post.code_type','');

            $data = array(
                'mobile'=>$mobile,
                'code'=>$code,
                'code_type'=>$code_type,
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Message_checkCode',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result= $service->callRemote("",$data,true);

            $this->parseResult($result);
        }
        $this->display();
    }


    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}